package com.resou.reader.discovery.comment.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.resou.reader.R;
import com.resou.reader.api.entry.BookListCommentBean;
import com.resou.reader.utils.DateUtil;
import com.resou.reader.utils.DateUtils;

import java.util.List;

public class CommentAdapter extends BaseQuickAdapter<BookListCommentBean.CommentsBean, BaseViewHolder> {
    public CommentAdapter(int layoutResId, @Nullable List<BookListCommentBean.CommentsBean> data) {
        super(layoutResId, data);
    }

    public CommentAdapter(@Nullable List<BookListCommentBean.CommentsBean> data) {
        super(data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BookListCommentBean.CommentsBean item) {
        Glide.with(mContext).load(item.getHeadPic() == null ? "" : item.getHeadPic()).into((ImageView) helper.getView(R.id.mCircleImageView));
        helper.setText(R.id.tvTitle, item.getNickName() + "");
        helper.setText(R.id.tvContent, item.getComment());
        helper.setText(R.id.tvTime, DateUtils.transferLongToDate("yyyy-MM-dd",
                item.getCommentDateMill()));
        helper.setText(R.id.tvPraiseNum, item.getCommentLike() + "");
        helper.setText(R.id.tvCommentNum, item.getReplyCount() + "");
    }
}
